package net.dengzixu.java.homework.period14.homework2;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author Deng Zixu <admin@dengzixu.com>
 */
public class Student {
    public String no;
    public String name;
    public String gender;
    public int age;
    public double score;

    private static List<Double> scoreList = new ArrayList<>();


    /**
     * 学生
     *
     * @param no     学号
     * @param name   姓名
     * @param gender 性别
     * @param age    年龄
     * @param score  分数
     */
    public Student(String no, String name, String gender, int age, double score) {
        this.no = no;
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.score = score;

        scoreList.add(score);
    }

    public double max() {
        scoreList.sort(Comparator.reverseOrder());
        return scoreList.get(0);
    }

    public double min() {
        scoreList.sort(Comparator.naturalOrder());
        return scoreList.get(0);
    }

    public double avg() {
        var total = 0;

        for (double s : scoreList) {
            total += s;
        }

        return total / (double) scoreList.size();

    }


}
